package com.dex4d.ui.main.model;

import android.os.Parcel;
import android.os.Parcelable;

import com.google.gson.annotations.Expose;

import java.util.Comparator;

/**
 * 作者    LiQingyi
 * 时间    2018/10/31 19:14
 * 文件    dex4d-android
 * 描述
 */
public class TokenDetail implements Comparator<TokenDetail>, Parcelable {

    /**
     * symbol : eth
     * buy_price : 8.9387E-4
     * sell_price : 8.1652E-4
     * overall_volume : 72.26658
     * dividends : 3.052824
     * daily_volume : 9.211645
     * daily_dividends : 0.372084
     * price_flat : 0.17
     * market_cap_flat : 10010.49
     * price_flat_cny : 1.18
     * market_cap_flat_cny : 70474.83
     * total_token : 85941.562136
     * whitout_fee_price : 8.5949E-4
     * pre_24hours_price : 7.3705E-4
     */

    public String symbol;

    @Expose
    public String logo;

    public int state;  //阶段，大使、新、退等
    public String ambassador_begin; //大使开始时间
    public String ambassador_end; //大使结束时间
    public String offline_time; //下线时间

    public String buy_price;
    public String sell_price;
    public String overall_volume;
    public String dividends;
    public String daily_volume;
    public String daily_dividends;
    public String price_flat;
    public String market_cap_flat;
    public String price_flat_cny;
    public String market_cap_flat_cny;
    public String total_token;

    public String whitout_fee_price;
    public String pre_24hours_price;
    /**
     * time : 1539086813
     * type : withdraw
     * status : Success
     * Tokens : Dex4D/eth
     * basis_balance : 0
     * denominated_balance : 0.922361
     * price : 0
     * id : 0x4bb1378bc22307d6e67795cd06377d3658fb76452c9ecda13edc652bd9755af6
     */

    public String time;
    public String type;
    public String status;
    public String Tokens;
    public String basis_balance;
    public String denominated_balance;
    public String price;
    public String id;


    @Override
    public String toString() {
        return "TokenDetail{" +
                "time='" + time + '\'' +
                ", type='" + type + '\'' +
                ", status='" + status + '\'' +
                ", Tokens='" + Tokens + '\'' +
                ", basis_balance='" + basis_balance + '\'' +
                ", denominated_balance='" + denominated_balance + '\'' +
                ", price='" + price + '\'' +
                ", id='" + id + '\'' +
                '}';
    }

    public TokenDetail() {
    }

    @Override
    public int compare(TokenDetail o1, TokenDetail o2) {
        if (o1.symbol.compareTo(o2.symbol) > 0) {
            return 1;
        } else if (o1.symbol.compareTo(o2.symbol) < 0) {
            return -1;
        } else {
            return 0;
        }

    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.symbol);
        dest.writeString(this.overall_volume);
        dest.writeString(this.dividends);

        dest.writeInt(this.state);
        dest.writeString(this.ambassador_begin);
        dest.writeString(this.ambassador_end);
        dest.writeString(this.offline_time);
    }

    protected TokenDetail(Parcel in) {
        this.symbol = in.readString();
        this.overall_volume = in.readString();
        this.dividends = in.readString();

        this.state = in.readInt();
        this.ambassador_begin = in.readString();
        this.ambassador_end = in.readString();
        this.offline_time = in.readString();
    }

    public static final Parcelable.Creator<TokenDetail> CREATOR = new Parcelable.Creator<TokenDetail>() {
        @Override
        public TokenDetail createFromParcel(Parcel source) {
            return new TokenDetail(source);
        }

        @Override
        public TokenDetail[] newArray(int size) {
            return new TokenDetail[size];
        }
    };
}
